
import java.util.ArrayList;
import java.util.Scanner;

/**
 * This class has all the InventoryModel
 *
 */
public class InventoryModel {
                private final double MAXLBS = 2000;
        private double totalLbs;
        private ArrayList<Item> items;
        /**
         * This is the constructor where all the items are added onto the Items
         */
        private int spotX, spotY;
        
        public InventoryModel()
        {
                items = new ArrayList<Item>();
                
                items.add(new Item("Gas", 1));
                items.add(new Item("Food", 0));
                items.add(new Item("Clothes", 0));
                items.add(new Item("Ammunition", 0));
                items.add(new Item("Spare Wheels", 0));
                items.add(new Item("Spare Axles", 0));
                items.add(new Item("Spare Engine", 0));
                
                for (int i = 0; i < items.size(); i++) {
                        totalLbs += items.get(i).getQuantity() * items.get(i).getWeight();
                }
        }
        
        /**
         * This method gets the total weight of the inventory
         * @return totalLbs             totalLbs is the weight of inventory
         */
        public double getTotalLbs() {
                return totalLbs;
        }
        /**
         * This method sets the weight of the inventory
         * @param totalLbs              totalLibs is the weight of inventory
         */
        public void setTotalLbs(double totalLbs) {
                this.totalLbs = totalLbs;
        }
        
        public void addLbs(double lbsToAdd) {
                totalLbs = totalLbs + lbsToAdd;
        }
        
        public void subtractLbs(double lbsToSubtract) {
                totalLbs = totalLbs - lbsToSubtract;
        }
        
        /**
         * This method gets the ArrayList of Items
         * @return items                items is the ArrayList of the items             
         */
        public ArrayList<Item> getItems() {
                return items;
        }
        /**
         * This method sets the items
         * @param items                 items is the ArrayList of the Items
         */
        public void setItems(ArrayList<Item> items) {
                this.items = items;
        }
        
        public String getQuantitiesStr()
        {
        	String output = "";
        	for(int i = 0; i < items.size(); i++)
        	{
        		output += items.get(i).getQuantity() + " ";
        	}
        	
        	return output;
        }
        
        public void setQuantities(String quantities)
        {
        	Scanner inStr = new Scanner(quantities);
        	for(int i = 0; i < items.size(); i++)
        	{
        		items.get(i).setQuantity(Integer.parseInt(inStr.next()));
        	}
        	
        	inStr.close();
        }
        
        public boolean checkWeightOK(double addedWeight) {
                if (totalLbs + addedWeight < MAXLBS) {
                        return true;
                } else {
                        return false;
                }
        }
}